//
//  PKCommentBar.swift
//  Panku
//
//  Created by mac on 2017/5/22.
//  Copyright © 2017年 Monster. All rights reserved.
//

import UIKit
import YYKit

class PKCommentBar: PKBaseView {
    
    //MARK:UI
    lazy var thumbUpButton = PKBaseButton.createButton()
    lazy var commentButton = PKBaseButton.createButton()
    lazy var shareButton = PKBaseButton.createButton()
    
    var thumbUpCallback:(()->Void)?
    var commentCallback:(()->Void)?
    var shareCallback:(()->Void)?
    
    init(thumbUpCallback:(()->Void)?,commentCallback:(()->Void)?,shareCallback:(()->Void)?) {
        super.init()
        
        self.thumbUpCallback = thumbUpCallback
        self.commentCallback = commentCallback
        self.shareCallback = shareCallback
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func setupView() {
        super.setupView()
        
        addSubview(thumbUpButton)
        addSubview(commentButton)
        addSubview(shareButton)
        
        self.layer.shadowColor = UIColor.black.cgColor
//        self.layer.shadowOpacity = 0.3
        self.layer.shadowOffset = CGSize(width: 10, height: 10)
        
        thumbUpButton.setImage(R.image.commentBar_thumbUp(), for: .normal)
        thumbUpButton.setImage(R.image.commentBar_thumbUp_selected(), for: .selected)
        commentButton.setImage(R.image.commentBar_comment(), for: .normal)
        shareButton.setImage(R.image.commentBar_share(), for: .normal)
        
        
        thumbUpButton.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.left.equalTo(self.snp.left).offset(35)
            
        }
        
        thumbUpButton.addBlock(for: .touchUpInside) { (_) in
            self.thumbUpCallback!()
        }
        
        commentButton.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.left.equalTo(thumbUpButton.snp.right).offset(70)
        }
        
        commentButton.addBlock(for: .touchUpInside) { (_) in
            self.commentCallback!()
        }
        
        shareButton.snp.makeConstraints { (make) in
            make.centerY.equalTo(self.snp.centerY)
            make.right.equalTo(self.snp.right).offset(-37)
        }
        
        shareButton.addBlock(for: .touchUpInside) { (_) in
            self.shareCallback!()
        }
        
        
    }

}
